package com.itheima.tlias84.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.tlias84.dto.SelectClassDTO;
import com.itheima.tlias84.mapper.ClassMapper;
import com.itheima.tlias84.po.SelectClassPageParam;
import com.itheima.tlias84.service.ClassService;
import com.itheima.tlias84.utils.ResultUtil;
import com.itheima.tlias84.vo.PageVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {
    @Resource
    ClassMapper classMapper;


    @Override
    public ResultUtil selectClassByPage(SelectClassPageParam param) {
        Page<Object> page = PageHelper.startPage(param.getPage(), param.getPageSize());
        List<SelectClassDTO> dtos = classMapper.selectClassByPage(param);
        PageVO<SelectClassDTO> pageVo = new PageVO<>();
        pageVo.setTotal(page.getTotal());
        pageVo.setRows(dtos);
        return ResultUtil.success(pageVo);
    }
}
